package com.equipment.system.web.api;

import com.baomidou.mybatisplus.plugins.Page;
import com.equipment.system.entity.Equipment;
import com.equipment.system.service.FaultInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 设备故障
 *
 * @author 杨凯
 * @create 2018-04-02 11:16
 **/
@RestController
@RequestMapping("/fault")
public class FaultController {

	@Autowired
	private FaultInfoService faultInfoService;

	@GetMapping("/list")
	public Map<String, Object> equipmentList(@RequestParam(defaultValue = "0") int start, @RequestParam(defaultValue = "10") int length, @RequestParam("province") String province) {
		Map<String, Object> map = new HashMap<>(3);
		Page page = new Page(start, length);
		Page<Equipment> paperPage = faultInfoService.selectPage(page);
		List<Equipment> list = paperPage.getRecords();
		map.put("data", list);
		map.put("count", paperPage.getTotal());
		return map;
	}
}
